﻿
#ifndef _COM_FUN_H_
#define _COM_FUN_H_
 

#include "commDef.h" 


#ifndef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif

#ifndef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#endif

#ifndef ABS
#define ABS(x)   ((x) >= 0 ? (x) : -(x))
#endif 
   
#ifndef WIN32

#define LPTHREAD_START_ROUTINE   void*(*)(void*)
inline pthread_t XCreateThread ( 
		  void* (*lpStartAddress)(void*)  ,
		  void*  ThreadParameter 
		)
{                    
             
	pthread_t   threadId;
	pthread_attr_t attr;

	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

	pthread_create(&threadId, &attr, (void*(*)(void*))lpStartAddress, ThreadParameter);


	pthread_attr_destroy(&attr);
	
	return threadId;
}
#endif
 
#endif